/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 型材库类型枚举
 *
 * @author hxloongs
 * @date 2024-7-29
 */
@AllArgsConstructor
@Getter
public enum IsfdSectionTypeEnum {

    ALL("ALL", "抽象公用类型"),
    CAP("CAP", "帽型长桁结构"),
    T("T", "T型结构"),
    I("I", "I型结构"),
    FI("FI", "I型钛合金加强框"),

    FZ("FZ", "Z型框结构"),
    FZFF("FZFF", "复材浮框"),
    FZAFF("FZAFF", "Z型铝合金浮框"),

    FC("FC", "C型框结构"),
    FCSF("FCSF", "C型金属加强框"),

    FL("FL", "L型复材浮框角片"),
    FLATI("FLATI", "L型铝钛合金浮框角片"),
    FLA("FLA", "L型铝合金浮框角片"),

    FGO("FGO", "复材框外缘"),
    FGM("FGM", "复材框中缘"),
    FGI("FGI", "复材框内缘"),
    FGATIW("FGATIW", "铝（钛）矩形框缘_宽厚"),
    FGTI("FGTI", "钛合金中框缘"),
    FGA("FGA", "铝合金中框缘");

    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdSectionTypeEnum isfdSectionTypeEnum = forValue(value);
        if (isfdSectionTypeEnum == null) {
            return null;
        }
        return isfdSectionTypeEnum.getDesc();
    }

    public static IsfdSectionTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdSectionTypeEnum isfdSectionTypeEnum : IsfdSectionTypeEnum.values()) {
            if (isfdSectionTypeEnum.getValue().equals(value)) {
                return isfdSectionTypeEnum;
            }
        }
        return null;
    }

    public static IsfdSectionTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdSectionTypeEnum isfdSectionTypeEnum : IsfdSectionTypeEnum.values()) {
            if (desc.equals(isfdSectionTypeEnum.getDesc())) {
                return isfdSectionTypeEnum;
            }
        }
        return null;
    }
}
